package com.springboot.activemq.queue;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jms.core.JmsMessagingTemplate;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.jms.Queue;
import java.util.Date;

/**
 * 定时发送生产者
 * @date 2020/10/8 15:59
 */
//@Component
public class TimingQueueProducer {

    @Autowired
    private JmsMessagingTemplate jmsMessagingTemplate;

    @Autowired
    private Queue queue;

    @SuppressWarnings("depercation")
//    延时发送单位为毫秒
    @Scheduled(fixedDelay = 2000)
    public void produceMsg(){
        jmsMessagingTemplate.convertAndSend(queue,"定时发送的message:"+new Date().getTime());
    }

}
